#include "StdAfx.h"

SWEGL_DXWRAPPER_IMPLEMENT_IUNKNOWN(myIDirect3DTexture9, IDirect3DTexture9);

myIDirect3DTexture9::myIDirect3DTexture9(swegl::Texture *tex) : m_tex(tex)
{
	sweglInfo("%s\n", SWEGL_FUNCTION);
	SWEGL_DXWRAPPER_INIT_IUNKNOWN();
	for (size_t i = 0; i < m_tex->numSurfaces(); i++)
	{
		m_surfaces.push_back(new myIDirect3DSurface9(m_tex->surface(i)));
	}
}

myIDirect3DTexture9::~myIDirect3DTexture9()
{
}

HRESULT myIDirect3DTexture9::GetDevice(IDirect3DDevice9** ppDevice)
{
    SWEGL_DXWRAPPER_NYI(); return E_NOTIMPL;
}

HRESULT myIDirect3DTexture9::SetPrivateData(REFGUID refguid,CONST void* pData,DWORD SizeOfData,DWORD Flags)
{
    SWEGL_DXWRAPPER_NYI(); return E_NOTIMPL;
}

HRESULT myIDirect3DTexture9::GetPrivateData(REFGUID refguid,void* pData,DWORD* pSizeOfData)
{
    SWEGL_DXWRAPPER_NYI(); return E_NOTIMPL;
}

HRESULT myIDirect3DTexture9::FreePrivateData(REFGUID refguid)
{
    SWEGL_DXWRAPPER_NYI(); return E_NOTIMPL;
}

DWORD myIDirect3DTexture9::SetPriority(DWORD PriorityNew)
{
    SWEGL_DXWRAPPER_NYI(); return E_NOTIMPL;
}

DWORD myIDirect3DTexture9::GetPriority()
{
    SWEGL_DXWRAPPER_NYI(); return E_NOTIMPL;
}

void myIDirect3DTexture9::PreLoad()
{
    sweglInfo("%s: NYI\n", SWEGL_FUNCTION);
}

D3DRESOURCETYPE myIDirect3DTexture9::GetType()
{
	return D3DRTYPE_TEXTURE;
}

DWORD myIDirect3DTexture9::SetLOD(DWORD LODNew)
{
	sweglInfo("%s: NYI\n", SWEGL_FUNCTION);
    return 0;
}

DWORD myIDirect3DTexture9::GetLOD()
{
	sweglInfo("%s: NYI\n", SWEGL_FUNCTION);
    return 0;
}

DWORD myIDirect3DTexture9::GetLevelCount()
{
	sweglInfo("%s\n", SWEGL_FUNCTION);
	return m_tex->numSurfaces();
}

HRESULT myIDirect3DTexture9::SetAutoGenFilterType(D3DTEXTUREFILTERTYPE FilterType)
{
    SWEGL_DXWRAPPER_NYI(); return E_NOTIMPL;
}

D3DTEXTUREFILTERTYPE myIDirect3DTexture9::GetAutoGenFilterType()
{
    sweglInfo("%s: NYI\n", SWEGL_FUNCTION); return D3DTEXF_NONE;
}

void myIDirect3DTexture9::GenerateMipSubLevels()
{
	sweglInfo("%s: NYI\n", SWEGL_FUNCTION);
}

HRESULT myIDirect3DTexture9::GetLevelDesc(UINT Level,D3DSURFACE_DESC *pDesc)
{
    sweglInfo("%s: level %d\n", SWEGL_FUNCTION, Level);
	return m_surfaces[Level]->GetDesc(pDesc);
}

HRESULT myIDirect3DTexture9::GetSurfaceLevel(UINT Level,IDirect3DSurface9** ppSurfaceLevel)
{
	sweglInfo("%s: %d : %p\n", SWEGL_FUNCTION, Level, m_surfaces[Level]);
	*ppSurfaceLevel = m_surfaces[Level];
	(*ppSurfaceLevel)->AddRef();
	return S_OK;
}

HRESULT myIDirect3DTexture9::LockRect(UINT Level,D3DLOCKED_RECT* pLockedRect,CONST RECT* pRect,DWORD Flags)
{
    SWEGL_DXWRAPPER_NYI(); return E_NOTIMPL;
}

HRESULT myIDirect3DTexture9::UnlockRect(UINT Level)
{
    SWEGL_DXWRAPPER_NYI(); return E_NOTIMPL;
}

HRESULT myIDirect3DTexture9::AddDirtyRect(CONST RECT* pDirtyRect)
{
    SWEGL_DXWRAPPER_NYI(); return E_NOTIMPL;
}
